//
//  TTSTitleView.m
//  TTSAmericanMovie
//
//  Created by chenHR on 16/1/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TTSTitleView.h"

@interface TTSTitleView ()


@end

@implementation TTSTitleView

- (instancetype)initWithFrame:(CGRect)frame withTitleName:(NSString *)title{
    self = [super initWithFrame:frame];
    if (self) {
        [self TTSCreateSubViewsWithTitle:title];
    }
    
    return self;
}
- (void)TTSCreateSubViewsWithTitle:(NSString *)title{
    UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(7
                                                                , 7, 90, 40)];
//    titleL.backgroundColor = [UIColor blueColor];
    titleL.text = title;
    titleL.font = [UIFont systemFontOfSize:20];
    titleL.textColor = [UIColor whiteColor];
    [titleL sizeToFit];
    [self addSubview:titleL];
    
    if ([title isEqualToString:@"追剧"]) {
        [self TTSCreateButtons];
    }
    
}
- (void)TTSCreateButtons{
    UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [searchBtn setBackgroundImage:[UIImage imageNamed:@"iconfont-search"] forState:UIControlStateNormal];
    searchBtn.frame = CGRectMake(WIDTH-130, 12, 20, 20);
    [searchBtn addTarget:self action:@selector(searchBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:searchBtn];
    
    UIButton *historyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [historyBtn setBackgroundImage:[UIImage imageNamed:@"iconfont-lishi"] forState:UIControlStateNormal];
    historyBtn.frame = CGRectMake(WIDTH-90, 12, 20, 20);
    [historyBtn addTarget:self action:@selector(historyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:historyBtn];
    
    UIButton *categoryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [categoryBtn setBackgroundImage:[UIImage imageNamed:@"iconfont-category"] forState:UIControlStateNormal];
    categoryBtn.frame = CGRectMake(WIDTH-50, 10, 45, 22);
    [categoryBtn addTarget:self action:@selector(categoryBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:categoryBtn];
    
    
    
}

- (void)searchBtnAction:(UIButton *)btn{
    NSLog(@"搜索");
}
- (void)historyBtnAction:(UIButton *)btn{
    NSLog(@"历史");
}
- (void)categoryBtnAction:(UIButton *)btn{
    NSLog(@"分类");
}





















@end
